<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/18
 * Time: 10:17
 */

namespace App\Http\Controllers\MiniProgramAdmin;


use App\Http\Logics\MiniProgramAdmin\UserLogic;
use App\Http\Traits\UserTrait;
use App\Http\Controllers\BaseController;
class UserController extends BaseController
{
    use UserTrait;

    /**
     * @SWG\Post(
     *     path="/user/createMiniProgramQrcode",
     *     tags={"User"},
     *     description="获取管理员授权二维码",
     *     operationId="createMiniProgramQrcode",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥，并且通过loginSession获取合作者信息",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="page",
     *         in="query",
     *         description="要生成二维码的小程序页面路径",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="scene",
     *         in="query",
     *         description="小程序码参数",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createMiniProgramQrcode()
    {
        $loginSession = $this->loginSession;
        $page = $this->page;
        $scene = $this->scene;
        $data = [
            'loginSession' => $loginSession,
            'page' => $page,
            'scene' => $scene
        ];
        $response = UserLogic::createMiniProgramQrcode($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/user/getAssistantList",
     *     tags={"User"},
     *     description="获取管理员列表",
     *     operationId="getAssistantList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥，并且通过loginSession获取合作者信息",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getAssistantList()
    {
        $loginSession = $this->loginSession;
        $data = [
            'loginSession' => $loginSession
        ];
        $response = UserLogic::getAssistantList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/user/infoByUserId",
     *     tags={"User"},
     *     description="合作者通过user_id获取用户的信息",
     *     operationId="getUserInfoByUserId",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥，并且通过loginSession获取合作者信息",
     *         required=false,
     *         type="string",
     *         @SWG\Items(type="string"),
     *         collectionFormat="csv"
     *     ),
     *     @SWG\Parameter(
     *         name="user_id",
     *         in="query",
     *         description="用户ID",
     *         required=false,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getUserInfoByUserId()
    {
        $user_id = $this->user_id;
        $loginSession = $this->loginSession;
        $data = [
            'user_id' => $user_id,
            'loginSession' => $loginSession
        ];
        $response = UserLogic::getUserInfoByUserId($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/user/getManageCityList",
     *     tags={"User"},
     *     description="获取用户管理的城市列表",
     *     operationId="getManageCityList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string",
     *         @SWG\Items(type="string"),
     *         collectionFormat="csv"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getManageCityList()
    {
        $loginSession = $this->loginSession;
        $data = [
            'loginSession' => $loginSession
        ];
        $response = UserLogic::getManageCityList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}